﻿using PracticeCentre.Business;
using PracticeCentre.Common;
using PracticeCentre.Modeles;
using PracticeCentre.Mvc.Filters;
using PracticeCentre.Mvc.Helper;
using PracticeCentre.Mvc.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace PracticeCentre.Mvc.Controllers
{
    public class PersonalController : BaseController
    {
        private JsonResult result;
        [LoginIntercept]
        public ActionResult Index()
        {
            return View();
        }
        [LoginIntercept]
        [HttpPost]
        public ActionResult Index(PageViewModel model)
        {
            //将视图数据映射到业务逻辑数据
            PageModel<Personal> pagemodel = ModelesMapping.Mapping<PageModel<Personal>, PageViewModel>(model);
            PersonalInfo personal = new PersonalInfo();
            //查询数据列表
            pagemodel = personal.GetPersonalList(pagemodel);
            string data = JsonTool.JsonSerializer(pagemodel);
            result = DataHelper.GetResult(ExecuteState.Succeed, "获取列表成功！", data);
            return result;
        }

        [LoginIntercept]
        public ActionResult Details(int id)
        {
            Personal model = new Personal();
            model.Id = id;
            PersonalInfo personal = new PersonalInfo();
            model= personal.GetModelById(model);
            return View(model);
        }

        [LoginIntercept]
        public ActionResult Add()
        {
            return View();
        }

        [LoginIntercept]
        [HttpPost]
        public ActionResult Add(Personal model)
        {
            return View();
        }

        [LoginIntercept]
        [HttpPost]
        public ActionResult Update(Personal model)
        {
            return View();
        }

    }
}